<?php

use yii\helpers\Html;
use yii\grid\GridView;
/* @var $this yii\web\View */
/* @var $searchModel backend\models\ArtcileSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = '文章列表';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="artcile-index col-sm-12 " style="margin-top: 15px;">
    <p>
        <?= Html::a('新建文章', ['create'], ['class' => 'btn btn-success']) ?>
    </p>
<div class="ibox ibox-content float-e-margins>
    <?php  echo $this->render('_search', ['model' => $searchModel]); ?>

    <?= GridView::widget([
        'dataProvider' => $dataProvider,

    'tableOptions' => ['class' => 'table table-hover'],
        'columns' => [
            ['class' => 'yii\grid\SerialColumn','header'=>'序号'],

            'title',
            'content:ntext',
            [
                'attribute' => 'status',
                'value' => function ($m) {
                 return \common\models\Artcile::$status[$m->status];

                }
            ],
            'name0.username',

            ['attribute'=>'create_time',
                'value'=>function($m){
                   return date('Y-m-d',$m->create_time);
                }
                ],

            ['class' => 'yii\grid\ActionColumn',
             'header' => '操作',
             'headerOptions' => ['width'=>'150px'],
                'template' => '{update}  {view} {delete}',
                'buttons' => [
                    'update' => function($url, $model, $key){
                        return Html::a('修改', $url,['class' =>'btn btn-outline btn-warning btn-xs']);
                    },
                      'view' => function($url, $model, $key){
                        return Html::a('查看', $url,['class' =>'btn btn-outline btn-warning btn-xs']);
                    },
                      'delete' => function($url, $model, $key){
                        return Html::a('删除', $url,['class' =>'btn btn-outline btn-warning btn-xs']);
                    },
                    ]
            ],
        ],
    ]); ?>
</div>
</div>
